package com.hjy.exception;

import lombok.Data;

@Data
public class CfmsException extends RuntimeException {
    private CfmsErrorType CfmsErrorType = com.hjy.exception.CfmsErrorType.ERROR_INTERNAL_ERROR;
    private String details = "";

    protected CfmsException(String message, Throwable cause,
                            boolean enableSuppression,
                            boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.details = cause.getMessage();
    }

    public CfmsException(CfmsErrorType errorType) {
        super(errorType.getMsg());
        this.CfmsErrorType = errorType;
        this.details = "";
    }

    public CfmsException(CfmsErrorType errorType, Throwable cause) {
        super(errorType.getMsg(), cause);
        this.CfmsErrorType = errorType;
        this.details = cause.getMessage();
    }

    public CfmsException(CfmsErrorType errorType, String cause) {
        super(errorType.getMsg());
        this.CfmsErrorType = errorType;
        this.details = cause;
    }


    public CfmsErrorType getCfmsErrorType() {
        return CfmsErrorType;
    }

    public String getDetails() {
        return details;
    }

}
